/**
 * 
 */
package dms.presentation.form.student;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import dms.dto.StudentDTO;

/**
 * @author 李健
 *
 */
public class StudentModifyForm extends StudentDTO {
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		String password = this.getPassword();
		String oldPassword = this.getOldPassword();
		String email = this.getEmail();
		String oldEmail = this.getOldEmail();
		String telephone = this.getTelephone();
		
		if (oldPassword != null && oldPassword.length() != 0) {
			if (password == null || password.length() == 0) {
				errors.add("password", new ActionMessage("原密码和新密码必须同时填写", false));
			}
		}
		if (oldEmail != null && oldEmail.length() != 0) {
			if (email == null || email.length() == 0) {
				errors.add("email", new ActionMessage("原邮件和新邮件必须同时填写", false));
			}
		}
		return errors;
	}
}
